package com.bq.gametrade.ui.dialog;

import android.app.Activity;
import android.content.ClipboardManager;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.bq.gametrade.R;
import com.bq.gametrade.utils.ToastUtils;

/**
 * Created by Feel on 2016/12/23.
 */

public class PermissionPromptDialog extends DialogFragment {

    private TextView tvConfirm;

    private Activity activity;


    public interface OnNextClickListener {
        public void onNextListener();
    }


    private OnNextClickListener nextClickListener;

    public OnNextClickListener getNextClickListener() {

        return this.nextClickListener;
    }

    public void setNextClickListener(OnNextClickListener nextClickListener) {
        this.nextClickListener = nextClickListener;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = getActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.dialog_permissionprompt, container);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

        Window window = getDialog().getWindow();

        WindowManager.LayoutParams lp = window.getAttributes();
        window.setGravity(Gravity.CENTER);
        window.setAttributes(lp);
        getDialog().show();
        initView(view);
        return view;

    }

    private void initView(View view) {
        tvConfirm = (TextView) view.findViewById(R.id.tv_confirm);
        tvConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                nextClickListener.onNextListener();
                dismiss();
            }
        });
    }
}
